
// 组队界面点击全组按钮  批量通过组队申请
// @ts-ignore
export async function execute(client_id,message_json) {
    let login_characters = G.Characters.get_current_login_characters(client_id);
    if (!login_characters["队长"]) {
        ClientUtils.send_basic_prompt(client_id, "你不是队长没有权限操作");
        return;
    }
    let team_data = G.TeamUtils.get_team_data(login_characters["队伍"]);

    if (team_data === undefined) {
        ClientUtils.send_basic_prompt(client_id, "队伍已不存在");
        return;
    }
    if (team_data["申请"].length === 0) {
        ClientUtils.send_basic_prompt(client_id, "#当前还没有收到入队申请信息");
    }
    let apply_list = team_data["申请"];
    //遍历所有申请信息
    for (let index = 0; index < apply_list.length; index++) {
        let apply_characters = apply_list[index];
        //尝试同意申请并将角色加入队伍
        let characters = _CharactersData.get(apply_characters["id"]);
        if (characters !== undefined) {
            //成功则更新申请列表
            if (G.TeamUtils.add_characters_to_team(client_id, team_data["id"], apply_characters["id"])) {
                team_data = G.TeamUtils.get_team_data(team_data["id"]);
                team_data["申请"].splice(index, 1);
            } else {
                //失败直接退出处理
                break;
            }
        } else {
            //离线 直接从申请列表删除
            team_data["申请"].splice(index, 1);
        }

    }
}